<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Video List</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 20px;
        }
        .container {
            text-align: center;
            margin-top: 50px;
        }
        h1 {
            color: #333;
            margin-bottom: 20px;
        }
        .video-list {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
        }
        .video-item {
            background-color: #fff;
            border: 1px solid #ddd;
            border-radius: 5px;
            margin: 10px;
            padding: 10px;
            width: 300px;
            text-align: center;
        }
        .video-title {
            font-size: 18px;
            color: #333;
            margin-bottom: 10px;
        }
        .pagination {
            margin-top: 20px;
        }
        .pagination a {
            display: inline-block;
            padding: 5px 10px;
            margin: 0 5px;
            text-decoration: none;
            color: #fff;
            background-color: #007bff;
            border-radius: 5px;
            transition: background-color 0.3s;
        }
        .pagination a:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>视频列表</h1>
    <div class="video-list" th:if="${not #lists.isEmpty(videoPage.records)}">
        <div class="video-item" th:each="video : ${videoPage.records}">
            <div class="video-title" th:text="${video.title}"></div>
            <div class="video-info">
                <p>发布时间: <span th:text="${#dates.format(video.publishTime, 'yyyy-MM-dd HH:mm')}"></span></p>
                <p>播放次数: <span th:text="${video.playNums}"></span></p>
            </div>
            <video class="video-player" controls>
                <source th:src="${video.videoUrl}" type="video/mp4">
                您的浏览器不支持 video 标签。
            </video>
        </div>
    </div>
    <div th:unless="${not #lists.isEmpty(videoPage.records)}">
        <p>没有找到相关视频。</p>
    </div>
    <div class="pagination" th:if="${videoPage.pages > 1}">
        <a th:href="@{/video/search(keyword=${keyword}, pageNum=1, pageSize=${videoPage.size})}" th:if="${videoPage.current > 1}">首页</a>
        <a th:href="@{/video/search(keyword=${keyword}, pageNum=${videoPage.current - 1}, pageSize=${videoPage.size})}" th:if="${videoPage.current > 1}">上一页</a>
        <a th:href="@{/video/search(keyword=${keyword}, pageNum=${videoPage.current + 1}, pageSize=${videoPage.size})}" th:if="${videoPage.current < videoPage.pages}">下一页</a>
        <a th:href="@{/video/search(keyword=${keyword}, pageNum=${videoPage.pages}, pageSize=${videoPage.size})}" th:if="${videoPage.current < videoPage.pages}">尾页</a>
    </div>
     <a th:href="@{/video/mainpage}" class="back-btn">返回主界面</a>
</div>
</body>
</html>